import 'dart:typed_data';

import 'package:plugin_platform_interface/plugin_platform_interface.dart';

import 'updater_method_channel.dart';
import 'entity/download_status.dart';

abstract class AppUpdaterPlatform extends PlatformInterface {
  /// Constructs a AppUpdaterPlatform.
  AppUpdaterPlatform() : super(token: _token);

  static final Object _token = Object();

  static AppUpdaterPlatform _instance = MethodChannelAppUpdater();

  /// The default instance of [AppUpdaterPlatform] to use.
  ///
  /// Defaults to [MethodChannelAppUpdater].
  static AppUpdaterPlatform get instance => _instance;

  /// Platform-specific implementations should set this with their own
  /// platform-specific class that extends [AppUpdaterPlatform] when
  /// they register themselves.
  static set instance(AppUpdaterPlatform instance) {
    PlatformInterface.verifyToken(instance, _token);
    _instance = instance;
  }

  Future<String?> getPlatformVersion() {
    throw UnimplementedError('platformVersion() has not been implemented.');
  }

  Future<int> enqueueDownload({
    required String url,
    String? localPath,
    Map<String, String>? headers,
    String? title,
    String? description,
  }) {
    throw UnimplementedError('enqueueDownload() has not been implemented.');
  }

  Future<int> removeDownload(List<int> ids) {
    throw UnimplementedError('removeDownload() has not been implemented.');
  }

  Future<DownloadStatus?> getDownloadStatus(int id) {
    throw UnimplementedError('getDownloadStatus() has not been implemented.');
  }

  Future<Uri?> getUriForDownloadedFile(int id) {
    throw UnimplementedError(
        'getUriForDownloadedFile() has not been implemented.');
  }

  Future<Uint8List> calculateMD5Checksum(int id) {
    throw UnimplementedError(
        'calculateMD5Checksum() has not been implemented.');
  }

  Future<void> requestInstallAPK(String uriString) {
    throw UnimplementedError('requestInstallAPK() has not been implemented.');
  }
}
